var userInfo = {name:'myfuder'};

var Popularize = {
    init:function(){
        this.getData();
    },
    eventLisenter:function(){
        $(".intenthtml").click(function(){
            window.location.href=$(this).attr("href");
        });
    },
    getData:function(){
        new AjaxRequest({
            type: "get",
            url:apiService.mySpreadSummary,
            param: "",
            callBack:function(res){
                if(res.code==302){
                    window.location.href= res.url;
                }
                else if(res.success){
                    var payload = res.payload;
                    userInfo = res.userInfo;
                    $("#userName").text(userInfo.nickName);
                    $(".sumaward").html('<span style="color:#cba66a">￥</span>'+payload.sumAwardAmt);
                    $(".canwithdraw").html('<span style="color:#cba66a">￥</span>'+payload.canWithdrawAmt);
                    $(".myuser").text(payload.myUserCount+"人");
                    $(".myorder").text(payload.myOrderCount+"单");
                    $(".myspread").text(payload.mySpreadCount+"单");
                    $(".awardpool").text(payload.awardPoolRemainAmt);
                }else{
                    alert(res.message);
                }
                Popularize.getMarqueeData();
            },
            failBack: function(res){
                console.log(res);
                // $("#userName").text(userInfo.name);
            }
        });
    },
    getMarqueeData:function(){
        new AjaxRequest({
            type: "post",
            url: apiService.mySpreadAwardList+"?type=3",
            param: JSON.stringify({pageNo: 1, limit: 10}),
            callBack: function (res) {
                // 8月12日用户获得0奖励
                if(res.code==302){
                    window.location.href= res.url;
                }else if(res.success){
                    var data=res.payload.items;
                    var s = "";
                    for(var i=0;i<data.length;i++){
                        var r = `<span style="padding-left: 30px"></span>${data[i].awardDate}用户${data[i].nickname}获得${data[i].awardAmount}奖励`;
                        s +=r;
                    }
                    // alert(s);
                    $(".str1").html(s);
                    $('.str1').liMarquee();
                }else{
                    alert(res.message);
                }

            }
        })
    }
}

function detail(){

}
